package com.app.bimo.library_db.dao;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.app.bimo.library_db.BookClassDataConvert;
import com.app.bimo.library_db.BookExtData;
import com.app.bimo.library_db.BookExtDataConvert;
import java.util.List;

import com.app.bimo.library_db.BookData;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "BOOK_DATA".
*/
public class BookDataDao extends AbstractDao<BookData, String> {

    public static final String TABLENAME = "BOOK_DATA";

    /**
     * Properties of entity BookData.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Novelid = new Property(0, String.class, "novelid", true, "NOVELID");
        public final static Property Cover = new Property(1, String.class, "cover", false, "COVER");
        public final static Property NovelName = new Property(2, String.class, "novelName", false, "NOVEL_NAME");
        public final static Property AuthorName = new Property(3, String.class, "authorName", false, "AUTHOR_NAME");
        public final static Property Authorid = new Property(4, String.class, "authorid", false, "AUTHORID");
        public final static Property RankInfo = new Property(5, String.class, "rankInfo", false, "RANK_INFO");
        public final static Property PromotionType = new Property(6, int.class, "promotionType", false, "PROMOTION_TYPE");
        public final static Property IsComplete = new Property(7, int.class, "isComplete", false, "IS_COMPLETE");
        public final static Property LastChapterTitle = new Property(8, String.class, "lastChapterTitle", false, "LAST_CHAPTER_TITLE");
        public final static Property LastChapterName = new Property(9, String.class, "lastChapterName", false, "LAST_CHAPTER_NAME");
        public final static Property Summary = new Property(10, String.class, "summary", false, "SUMMARY");
        public final static Property LastChapterid = new Property(11, String.class, "lastChapterid", false, "LAST_CHAPTERID");
        public final static Property IsRecommend = new Property(12, int.class, "isRecommend", false, "IS_RECOMMEND");
        public final static Property LastChapterNumber = new Property(13, int.class, "lastChapterNumber", false, "LAST_CHAPTER_NUMBER");
        public final static Property ReadSchedule = new Property(14, String.class, "readSchedule", false, "READ_SCHEDULE");
        public final static Property UpdateChapterNum = new Property(15, int.class, "updateChapterNum", false, "UPDATE_CHAPTER_NUM");
        public final static Property LastReadTime = new Property(16, String.class, "lastReadTime", false, "LAST_READ_TIME");
        public final static Property CategoryNames = new Property(17, String.class, "categoryNames", false, "CATEGORY_NAMES");
        public final static Property IsVip = new Property(18, int.class, "isVip", false, "IS_VIP");
        public final static Property Uuid = new Property(19, String.class, "uuid", false, "UUID");
        public final static Property InBookself = new Property(20, int.class, "inBookself", false, "IN_BOOKSELF");
        public final static Property InDownLoad = new Property(21, int.class, "inDownLoad", false, "IN_DOWN_LOAD");
        public final static Property InReadRecord = new Property(22, int.class, "inReadRecord", false, "IN_READ_RECORD");
        public final static Property Ext = new Property(23, String.class, "ext", false, "EXT");
        public final static Property OrderTime = new Property(24, long.class, "orderTime", false, "ORDER_TIME");
    }

    private final BookClassDataConvert categoryNamesConverter = new BookClassDataConvert();
    private final BookExtDataConvert extConverter = new BookExtDataConvert();

    public BookDataDao(DaoConfig config) {
        super(config);
    }
    
    public BookDataDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"BOOK_DATA\" (" + //
                "\"NOVELID\" TEXT PRIMARY KEY NOT NULL ," + // 0: novelid
                "\"COVER\" TEXT," + // 1: cover
                "\"NOVEL_NAME\" TEXT," + // 2: novelName
                "\"AUTHOR_NAME\" TEXT," + // 3: authorName
                "\"AUTHORID\" TEXT," + // 4: authorid
                "\"RANK_INFO\" TEXT," + // 5: rankInfo
                "\"PROMOTION_TYPE\" INTEGER NOT NULL ," + // 6: promotionType
                "\"IS_COMPLETE\" INTEGER NOT NULL ," + // 7: isComplete
                "\"LAST_CHAPTER_TITLE\" TEXT," + // 8: lastChapterTitle
                "\"LAST_CHAPTER_NAME\" TEXT," + // 9: lastChapterName
                "\"SUMMARY\" TEXT," + // 10: summary
                "\"LAST_CHAPTERID\" TEXT," + // 11: lastChapterid
                "\"IS_RECOMMEND\" INTEGER NOT NULL ," + // 12: isRecommend
                "\"LAST_CHAPTER_NUMBER\" INTEGER NOT NULL ," + // 13: lastChapterNumber
                "\"READ_SCHEDULE\" TEXT," + // 14: readSchedule
                "\"UPDATE_CHAPTER_NUM\" INTEGER NOT NULL ," + // 15: updateChapterNum
                "\"LAST_READ_TIME\" TEXT," + // 16: lastReadTime
                "\"CATEGORY_NAMES\" TEXT," + // 17: categoryNames
                "\"IS_VIP\" INTEGER NOT NULL ," + // 18: isVip
                "\"UUID\" TEXT," + // 19: uuid
                "\"IN_BOOKSELF\" INTEGER NOT NULL ," + // 20: inBookself
                "\"IN_DOWN_LOAD\" INTEGER NOT NULL ," + // 21: inDownLoad
                "\"IN_READ_RECORD\" INTEGER NOT NULL ," + // 22: inReadRecord
                "\"EXT\" TEXT," + // 23: ext
                "\"ORDER_TIME\" INTEGER NOT NULL );"); // 24: orderTime
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"BOOK_DATA\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, BookData entity) {
        stmt.clearBindings();
 
        String novelid = entity.getNovelid();
        if (novelid != null) {
            stmt.bindString(1, novelid);
        }
 
        String cover = entity.getCover();
        if (cover != null) {
            stmt.bindString(2, cover);
        }
 
        String novelName = entity.getNovelName();
        if (novelName != null) {
            stmt.bindString(3, novelName);
        }
 
        String authorName = entity.getAuthorName();
        if (authorName != null) {
            stmt.bindString(4, authorName);
        }
 
        String authorid = entity.getAuthorid();
        if (authorid != null) {
            stmt.bindString(5, authorid);
        }
 
        String rankInfo = entity.getRankInfo();
        if (rankInfo != null) {
            stmt.bindString(6, rankInfo);
        }
        stmt.bindLong(7, entity.getPromotionType());
        stmt.bindLong(8, entity.getIsComplete());
 
        String lastChapterTitle = entity.getLastChapterTitle();
        if (lastChapterTitle != null) {
            stmt.bindString(9, lastChapterTitle);
        }
 
        String lastChapterName = entity.getLastChapterName();
        if (lastChapterName != null) {
            stmt.bindString(10, lastChapterName);
        }
 
        String summary = entity.getSummary();
        if (summary != null) {
            stmt.bindString(11, summary);
        }
 
        String lastChapterid = entity.getLastChapterid();
        if (lastChapterid != null) {
            stmt.bindString(12, lastChapterid);
        }
        stmt.bindLong(13, entity.getIsRecommend());
        stmt.bindLong(14, entity.getLastChapterNumber());
 
        String readSchedule = entity.getReadSchedule();
        if (readSchedule != null) {
            stmt.bindString(15, readSchedule);
        }
        stmt.bindLong(16, entity.getUpdateChapterNum());
 
        String lastReadTime = entity.getLastReadTime();
        if (lastReadTime != null) {
            stmt.bindString(17, lastReadTime);
        }
 
        List categoryNames = entity.getCategoryNames();
        if (categoryNames != null) {
            stmt.bindString(18, categoryNamesConverter.convertToDatabaseValue(categoryNames));
        }
        stmt.bindLong(19, entity.getIsVip());
 
        String uuid = entity.getUuid();
        if (uuid != null) {
            stmt.bindString(20, uuid);
        }
        stmt.bindLong(21, entity.getInBookself());
        stmt.bindLong(22, entity.getInDownLoad());
        stmt.bindLong(23, entity.getInReadRecord());
 
        BookExtData ext = entity.getExt();
        if (ext != null) {
            stmt.bindString(24, extConverter.convertToDatabaseValue(ext));
        }
        stmt.bindLong(25, entity.getOrderTime());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, BookData entity) {
        stmt.clearBindings();
 
        String novelid = entity.getNovelid();
        if (novelid != null) {
            stmt.bindString(1, novelid);
        }
 
        String cover = entity.getCover();
        if (cover != null) {
            stmt.bindString(2, cover);
        }
 
        String novelName = entity.getNovelName();
        if (novelName != null) {
            stmt.bindString(3, novelName);
        }
 
        String authorName = entity.getAuthorName();
        if (authorName != null) {
            stmt.bindString(4, authorName);
        }
 
        String authorid = entity.getAuthorid();
        if (authorid != null) {
            stmt.bindString(5, authorid);
        }
 
        String rankInfo = entity.getRankInfo();
        if (rankInfo != null) {
            stmt.bindString(6, rankInfo);
        }
        stmt.bindLong(7, entity.getPromotionType());
        stmt.bindLong(8, entity.getIsComplete());
 
        String lastChapterTitle = entity.getLastChapterTitle();
        if (lastChapterTitle != null) {
            stmt.bindString(9, lastChapterTitle);
        }
 
        String lastChapterName = entity.getLastChapterName();
        if (lastChapterName != null) {
            stmt.bindString(10, lastChapterName);
        }
 
        String summary = entity.getSummary();
        if (summary != null) {
            stmt.bindString(11, summary);
        }
 
        String lastChapterid = entity.getLastChapterid();
        if (lastChapterid != null) {
            stmt.bindString(12, lastChapterid);
        }
        stmt.bindLong(13, entity.getIsRecommend());
        stmt.bindLong(14, entity.getLastChapterNumber());
 
        String readSchedule = entity.getReadSchedule();
        if (readSchedule != null) {
            stmt.bindString(15, readSchedule);
        }
        stmt.bindLong(16, entity.getUpdateChapterNum());
 
        String lastReadTime = entity.getLastReadTime();
        if (lastReadTime != null) {
            stmt.bindString(17, lastReadTime);
        }
 
        List categoryNames = entity.getCategoryNames();
        if (categoryNames != null) {
            stmt.bindString(18, categoryNamesConverter.convertToDatabaseValue(categoryNames));
        }
        stmt.bindLong(19, entity.getIsVip());
 
        String uuid = entity.getUuid();
        if (uuid != null) {
            stmt.bindString(20, uuid);
        }
        stmt.bindLong(21, entity.getInBookself());
        stmt.bindLong(22, entity.getInDownLoad());
        stmt.bindLong(23, entity.getInReadRecord());
 
        BookExtData ext = entity.getExt();
        if (ext != null) {
            stmt.bindString(24, extConverter.convertToDatabaseValue(ext));
        }
        stmt.bindLong(25, entity.getOrderTime());
    }

    @Override
    public String readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0);
    }    

    @Override
    public BookData readEntity(Cursor cursor, int offset) {
        BookData entity = new BookData( //
            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // novelid
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // cover
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // novelName
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // authorName
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // authorid
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // rankInfo
            cursor.getInt(offset + 6), // promotionType
            cursor.getInt(offset + 7), // isComplete
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lastChapterTitle
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // lastChapterName
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // summary
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // lastChapterid
            cursor.getInt(offset + 12), // isRecommend
            cursor.getInt(offset + 13), // lastChapterNumber
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // readSchedule
            cursor.getInt(offset + 15), // updateChapterNum
            cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lastReadTime
            cursor.isNull(offset + 17) ? null : categoryNamesConverter.convertToEntityProperty(cursor.getString(offset + 17)), // categoryNames
            cursor.getInt(offset + 18), // isVip
            cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // uuid
            cursor.getInt(offset + 20), // inBookself
            cursor.getInt(offset + 21), // inDownLoad
            cursor.getInt(offset + 22), // inReadRecord
            cursor.isNull(offset + 23) ? null : extConverter.convertToEntityProperty(cursor.getString(offset + 23)), // ext
            cursor.getLong(offset + 24) // orderTime
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, BookData entity, int offset) {
        entity.setNovelid(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setCover(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setNovelName(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setAuthorName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setAuthorid(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setRankInfo(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setPromotionType(cursor.getInt(offset + 6));
        entity.setIsComplete(cursor.getInt(offset + 7));
        entity.setLastChapterTitle(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setLastChapterName(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setSummary(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setLastChapterid(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setIsRecommend(cursor.getInt(offset + 12));
        entity.setLastChapterNumber(cursor.getInt(offset + 13));
        entity.setReadSchedule(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setUpdateChapterNum(cursor.getInt(offset + 15));
        entity.setLastReadTime(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
        entity.setCategoryNames(cursor.isNull(offset + 17) ? null : categoryNamesConverter.convertToEntityProperty(cursor.getString(offset + 17)));
        entity.setIsVip(cursor.getInt(offset + 18));
        entity.setUuid(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
        entity.setInBookself(cursor.getInt(offset + 20));
        entity.setInDownLoad(cursor.getInt(offset + 21));
        entity.setInReadRecord(cursor.getInt(offset + 22));
        entity.setExt(cursor.isNull(offset + 23) ? null : extConverter.convertToEntityProperty(cursor.getString(offset + 23)));
        entity.setOrderTime(cursor.getLong(offset + 24));
     }
    
    @Override
    protected final String updateKeyAfterInsert(BookData entity, long rowId) {
        return entity.getNovelid();
    }
    
    @Override
    public String getKey(BookData entity) {
        if(entity != null) {
            return entity.getNovelid();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(BookData entity) {
        return entity.getNovelid() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
